<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link th:href="@{/css/style.css}" rel="stylesheet" type="text/css" />
<script type="text/javascript" th:src="@{/js/jquery.js}"></script>

<body>
<div class="place"> <span>位置：</span>
  <ul class="placeul">
    <li>采购管理</li>
    <li>采购单审核</li>
    <li>基本内容</li>
  </ul>
</div>
<div class="rightinfo">
  <form th:action="@{/purchaseExamine/lists}" method="post" name="conditionForm">
    <ul class="tools">
      <li> 采购单编号:
        <input type="text" name="purchaseId" th:value="${pParam.purchaseId}"/>
      </li>
      <li> 采购时间:
        <input type="date" name="startDate" th:value="${#dates.format(pParam.startDate,'yyyy-MM-dd')}"/>-
        <input type="date" name="endDate" th:value="${#dates.format(pParam.endDate,'yyyy-MM-dd')}"/>
      </li>
      <li> 金额:
        <input type="text" class="stinput" name="startMoney" th:value="${pParam.startMoney}"/>-<input type="text" class="stinput" name="endMoney" th:value="${pParam.endMoney}"/>
      </li>
      <li class="subBut" onclick="query()"><img th:src="@{/images/t06.png}" />查询</li>
      <li class="subBut" onclick="empty()"><img th:src="@{/images/t03.png}"/>清空</li>
    </ul>
    <table class="tablelist">
      <thead>
        <tr>
          <th>序号</th>
          <th>采购单编号</th>
          <th>采购时间</th>
          <th>金额</th>
          <th>操作人</th>
          <th>审核状态</th>
          <th>操作</th>
        </tr>
      </thead>
      <tbody>
        <tr th:each="cg,var:${CgPin.list}" th:switch="${cg.checkStatus}">
          <td th:text="${(CgPin.pageNum-1)*CgPin.pageSize+var.count}">1</td>
          <td th:text="${cg.purchaseId}">CG201701270001</td>
          <td th:text="${#dates.format(cg.purchaseTime,'yyyy-MM-dd')}">2017-01-25 15:05:05</td>
          <td th:text="'￥'+${cg.totalMoney}">￥9,876,582</td>
          <td th:text="${cg.creatUser.uname}">关羽</td>
          <td th:case="1">未审核</td>
          <td th:case="2">审核中</td>
          <td th:case="3">审核通过</td>
          <td th:case="4">审核未通过</td>
          <td>
            <a th:href="@{/purchaseExamine/toExamine?purchaseId=}+${cg.purchaseId}" class="tablelink">审核</a>
          </td>
        </tr>
      </tbody>
    </table>
    <div class="pagin">
      <div class="message">共<i class="blue" th:text="${CgPin.total}">1256</i>条记录，当前显示第&nbsp;<i class="blue" th:text="${CgPin.pageNum}">2&nbsp;</i>页</div>
      <ul class="paginList">
        <li class="paginItem" th:onclick="goPage([[${CgPin.pageNum-1}]])"><a href="javascript:;"><span class="pagepre"></span></a></li>
        <li class="paginItem" th:onclick="goPage(1)" th:class="${CgPin.pageNum==1?'paginItem current':'paginItem'}"><a href="javascript:;">1</a></li>

        <li th:each="p:${listPage}" th:class="${CgPin.pageNum==p?'paginItem current':'paginItem'}" th:onclick="goPage([[${p}]])"><a th:text="${p}" href="javascript:;">2</a></li>

        <li class="paginItem" th:if="${CgPin.pages!=1 and CgPin.pages!=0}" th:onclick="goPage([[${CgPin.pages}]])" th:class="${CgPin.pageNum==CgPin.pages?'paginItem current':'paginItem'}"><a href="javascript:;" th:text="${CgPin.pages}" id="pages" >10</a></li>
        <li class="paginItem"  th:onclick="goPage([[${CgPin.pageNum+1}]])"><a href="javascript:;"><span class="pagenxt"></span></a></li>
      </ul>
    </div>
  </form>
</div>
<script type="text/javascript">
  function empty() {
    $("input[name=purchaseId]").val("");
    $("input[name=startDate]").val("");
    $("input[name=endDate]").val("");
    $("input[name=startMoney]").val("");
    $("input[name=endMoney]").val("");
  }

  // 表单提交
  function query(){
    $("form[name=conditionForm]").submit();
  }

  // 页面跳转
  function goPage(num){
    var purchaseId = $("input[name=purchaseId]").val();
    var startDate = $("input[name=startDate]").val();
    var endDate = $("input[name=endDate]").val();
    var startMoney = $("input[name=startMoney]").val();
    var endMoney = $("input[name=endMoney]").val();
    var checkStatus = $("select[name=checkStatus]").val();

    // 最后一页
    var pages = $("#pages").text();
    if(num>=1 && num<=pages){
      location.href="/erp/purchaseExamine/lists?pageno="+num+"&purchaseId="+purchaseId+"&startDate="+startDate
              +"&endDate="+endDate+"&startMoney="+startMoney+"&endMoney="+endMoney;
    }
  }


  $('.tablelist tbody tr:odd').addClass('odd');
</script>
</body>
</html>
